    #ifndef MUSICPLAYER_H
#define MUSICPLAYER_H

#include <QWidget>
#include<btform.h>
#include<volumetool.h>
#include<musiclist.h>
#include<QMediaPlayer>
#include<commonpage.h>
#include<QMediaPlaylist>
#include"lrcpage.h"
#include<QPropertyAnimation>
#include<QSqlDatabase>




QT_BEGIN_NAMESPACE
namespace Ui { class MusicPlayer; }
QT_END_NAMESPACE

class MusicPlayer : public QWidget
{
    Q_OBJECT

public:
    MusicPlayer(QWidget *parent = nullptr);
    ~MusicPlayer();

    void initui();

    void initSqlite();
    void initMusicList();

    void connectSignalAndSlots();

    QJsonArray randomPiction();

    void initPlayer();

    void onPlayStateChanged();

    QString cacheFilePath(const QString &url);

private slots:
    void on_quit_clicked();
    void onBtFormClick(int pageId);

    void on_volume_clicked();

    void on_addLocal_clicked();
    void updateLikeMusicAndPage(bool isLike,const QString&musicId);
    void onPlayMusic();

    void onPlayUpClicked();
    void onPlayDownClicked();
    void onPlaybackModeClicked();
    void onPlaybackModeChanged(QMediaPlaylist::PlaybackMode playbackMode);
    void onPlayAll(MusicListType musicListType);
    void playAllMusicOfCommonPage(CommonPage*page,int index);
    void playMusicByIndex(CommonPage*page,int index);
    void onCurrentIndexChanged(int index);
    void setPlayMuted(bool isMuted);
    void onDurationChanged(qint64);
    void onPositionChanged(qint64 position);
    void onMusicSliderChanged(float ration);
    void onMetaDataAvailableChanged();

    void onLrcWordClicked();

    void on_min_clicked();

    void on_max_clicked();

    void MusicPlayerQuit();

    void onNetMusicListReady(MusicList netlist,QString listName);



protected:
    //窗口移动相关
    void mouseMoveEvent(QMouseEvent *event);
    void mousePressEvent(QMouseEvent *event);

signals:
    void playingMusicChanged();

private:
    Ui::MusicPlayer *ui;
    QPoint dragPosition;
    VolumeTool*volumeTool;
    MusicList musicList;
    QMediaPlayer*player;
    QMediaPlaylist*playList;
    CommonPage *currentPage;
    qint64 totalTime;
    int currentIndex;
    LrcPage*lrcPage;
    QPropertyAnimation *lrcPageAnimal;
    QSqlDatabase sqlite;

};
#endif // MUSICPLAYER_H
